<template>
  <div>
    <div style="display: flex; flex-direction: column">
      <div style="display: flex">
        <div class="upload-box">
          <div class="upload-content">
            <a-icon style="font-size: 24px; color: rgba(0, 0, 0, 0.45)" type="plus" />
            <span>上传视频</span>
          </div>
          <div class="self-com" v-if="!videoSrc">
            <storage-select placeholder="请选择视频" type="video" @onOk="selectCb"></storage-select>
          </div>
        </div>
        <div class="video-box" v-if="videoSrc">
          <video :src="videoSrc">您的浏览器不支持 video 标签！</video>
          <div class="action-hover">
            <div class="hover-bg"></div>
            <div class="hover-body">
              <div class="action-icons">
                <a-icon @click="toDelete" type="delete" />
              </div>
            </div>
          </div>
        </div>
      </div>
      <p
        style="
          margin: 10px 0px 0px;
          font-size: 14px;
          font-family: PingFangSC-Regular;
          line-height: 22px;
          color: rgba(0, 0, 0, 0.45);
        "
      >
        {{ helpText }}
      </p>
    </div>
  </div>
</template>

<script>
export default {
  components: {},
  props: {
    videoSrc: {
      type: String,
      default: '',
    },
    helpText: {
      type: String,
      default: '支持格式mp4;支持编码H.264;视频大小不能超过50M',
    },
  },
  data() {
    return {}
  },
  created() {},
  computed: {},
  mounted() {},
  methods: {
    // 删除视频
    toDelete() {
      this.$emit('deleteVideo')
    },
    // 上传成功回调
    selectCb(e) {
      console.log(e)
      this.$emit('uploadSuccess', {data: e})
    },
  },
}
</script>
<style lang="less" scoped>
.goods_pic_item_box {
  box-shadow: 0 0 5px rgba(170, 170, 170, 0.671);
  position: relative;
  width: 104px;
  height: 104px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(0, 0, 0, 0.14901960784313725);
  opacity: 1;
  border-radius: 4px;
  float: left;
  margin: 0 8px 0 0px;
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  .upload-img-box {
    width: 88px;
    height: 88px;
    position: relative;
    .action-hover {
      width: 100%;
      height: 100%;
      position: absolute;
      left: 0;
      top: 0;
      z-index: 11;
      display: none;
      opacity: 0;
      transition: all 0.3s;

      .hover-bg {
        width: 100%;
        height: 100%;
        background-color: #000000;
        opacity: 0.4;
      }
      .hover-body {
        width: 100%;
        height: 100%;
        position: absolute;
        left: 0;
        top: 0;
        z-index: 11;
        display: flex;
        justify-content: center;
        align-items: center;
      }
      .action-icons {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 5px;
        .anticon {
          color: #ffffff;
          font-size: 17px;
        }
        .anticon:nth-child(1) {
          margin-right: 10px;
        }
      }
    }
    img {
      width: 100%;
      height: 100%;
      display: block;
    }
  }
  .upload-img-box:hover > .action-hover {
    display: block;
    opacity: 1;
  }
}
.upload-box {
  width: 104px;
  height: 104px;
  background: rgba(0, 0, 0, 0.05);
  border: 1px dashed rgba(0, 0, 0, 0.14901960784313725);
  opacity: 1;
  border-radius: 4px;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  float: left;
  .upload-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
  }
  .self-com {
    opacity: 0;
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 111;
    /deep/.ant-btn {
      width: 104px;
      height: 103px;
    }
    /deep/.ant-input-group-wrapper {
      width: 104px;
      height: 104px;
      .ant-input-group {
        width: 100%;
        height: 100%;
        span:nth-child(1) {
          display: none;
        }
        span:nth-child(3) {
          width: 100%;
          height: 100%;
          position: absolute;
          left: 0;
          top: 0;
        }
      }
    }
  }
}
.video-box {
  width: 104px;
  height: 104px;
  position: relative;
  background: rgba(0, 0, 0, 0.05);
  border: 1px dashed rgba(0, 0, 0, 0.14901960784313725);
  opacity: 1;
  border-radius: 4px;
  margin-left: 8px;
  video {
    width: 100%;
    height: 100%;
  }
  .action-hover {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    z-index: 11;
    display: none;
    opacity: 0;
    transition: all 0.3s;
    background-color: #000000;
    opacity: 0.4;

    .hover-bg {
      width: 100%;
      height: 100%;
    }
    .hover-body {
      width: 100%;
      height: 100%;
      position: absolute;
      left: 0;
      top: 0;
      z-index: 11;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .action-icons {
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 5px;
      .anticon {
        color: #ffffff;
        font-size: 17px;
      }
      .anticon:nth-child(1) {
        margin-right: 10px;
      }
    }
  }
}
.video-box:hover > .action-hover {
  display: block;
}
</style>
